#include <cstring>
#include <iostream>
#include <string>
using namespace std;

bool valideKind(string& s) {
    int num = 0;
    int low = 0;
    int up = 0;
    int other = 0;
    for (int i = 0; i < s.length(); i++) {
        if ((s[i] - '0') >= 0 && (s[i] - '0') <= 9)
            num = 1;
        else if ((s[i] - 'a') >= 0 && (s[i] - 'a') <= 25)
            low = 1;
        else if ((s[i] - 'A') >= 0 && (s[i] - 'a') <= 25)
            up = 1;
        else
            other = 1;
    }
    return (num + low + up + other >= 3);
}

bool valideSub(string& s) {
    int len = s.length();
    for(int i=0;i<=len-3;i++){
        string key = s.substr(i,3);
        if(s.find(key, i+3) != string::npos) return 0;
    }
    return 1;
}

int main() {
    string s;
    cin >> s;

    if (!valideKind(s) || !valideSub(s) || s.length() <= 8) {
        cout << "NG" << endl;
        return 0;
    }

    cout << "OK" << endl;

    return 0;
}